import Http from '@/axios';
import { PageQuery } from '@/model/common';

import { DictTypeForm, DictTypeQuery } from '@/model/sys/dict_type';

export default class DictTypeApi {
    public static insert(form: DictTypeForm) {
        return Http.post(this.handleUrl('insert'), form);
    }

    public static update(form: DictTypeForm) {
        return Http.post(this.handleUrl('update'), form);
    }

    public static delete(id: string) {
        return Http.post(this.handleUrl('delete'), { id });
    }

    public static pageList(query: DictTypeQuery, page?: PageQuery) {
        return Http.get(this.handleUrl('list/page'), Object.assign(query, page));
    }

    public static info(id: string) {
        return Http.get(this.handleUrl('info'), { id });
    }

    public static listDict() {
        return Http.get(this.handleUrl('list/dict'));
    }

    private static handleUrl(relativeUrl: string) {
        return 'api/sys/dict_type/' + relativeUrl;
    }
}
